package com.example.myapplication;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatTextView;

import com.google.gson.Gson;

public class DetailActivity extends AppCompatActivity {

    private AppCompatTextView ipTextView;
    private AppCompatTextView contentTextView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //实例化控件
        setContentView(R.layout.activity_detail);
        ipTextView = findViewById(R.id.ipTextView);
        contentTextView = findViewById(R.id.contentTextView);
        //初始化数据
        IpBean ipBean = new Gson().fromJson(getIntent().getStringExtra("json"), IpBean.class);
        ipTextView.setText(ipBean.getIp());
        contentTextView.setText("省份：");
        contentTextView.append(ipBean.getPro() + "\n");
        contentTextView.append("省份编码：" + ipBean.getProCode() + "\n");
        contentTextView.append("城市：" + ipBean.getCity() + "\n");
        contentTextView.append("城市编码：" + ipBean.getCityCode() + "\n");
        contentTextView.append("地址：" + ipBean.getAddr() + "\n");
    }

}
